// static/js/common_req_json.js
// json 请求公共方法 :

function req_json(api_path, method, datas){
    fetch(api_path, {
        method: method,
        headers: {
            'Content-Type': 'application/json',
        },
        body: JSON.stringify({
            datas: datas,
        }),
        credentials: 'include'
    })
    .then(response => response.json())
    .then(data => {
        if (data.redirect) {
            window.location.href = data.redirect;
        } else {
            console.error('No redirect URL in response');
        }
    })
    .catch(error => console.error('Error:', error));

}